package com.wuliang.generate.common.sharding.factories;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.core.Ordered;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;

import javax.persistence.EntityManager;


/**
 * @author WuLiang
 */
public abstract class DataSourceConfigFactory implements Ordered {

    /**
     * 自动注入JPA的相关配置
     */
    @Autowired
    public JpaProperties jpaProperties;

    /**
     * 自动注入JPA的适配器
     */
    @Autowired
    public JpaVendorAdapter jpaVendorAdapter;

    /**
     * 配置实体类管理器
     */
    public abstract EntityManager entityManager();

    /**
     * 配置数据源事务管理器
     */
    public abstract JpaTransactionManager transactionManager();

    /**
     * 配置实体类管理器的创建者
     */
    public abstract EntityManagerFactoryBuilder entityManagerFactoryBuilder();

    /**
     * 配置实体类管理器工厂
     */
    public abstract LocalContainerEntityManagerFactoryBean entityManagerFactoryBean();

    @Override
    public int getOrder() {
        return -1000;
    }

}
